package com.hnust.dao;


import com.hnust.domain.TeaCourseGroup;
import com.hnust.domain.Teacher;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;
import com.hnust.domain.CourseGroup;
import com.hnust.domain.Course;
import java.util.List;

/**
 * 老师&课程组操作的DAO层
 * @author 焦硕洁
 * @date 2020/10/29
 */

import com.hnust.domain.CourseGroup;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.ResultType;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import com.hnust.domain.Course;
import java.util.List;

/**
 * 教师课程组表的DAO层
 * @author 42
 * @date 2020/10/29
 */
@Mapper
@Repository
public interface TeaCourseGroupDao {
    //获取课程组id
    @Select("select cou_gro_id from tea_course_group where tea_id = #{teacherId}")
    @ResultType(TeaCourseGroup.class)
    List<TeaCourseGroup> getCourseGroupId(String teacherId);

    //退出课程组
    @Delete("delete from tea_course_group where cou_gro_id = #{groupId} AND tea_id=#{teaId}")
    @ResultType(Integer.class)
    Integer deleteTeaCourseGroup(String groupId,String teaId);

    //删除正在审核的课程组
    @Delete("delete from `audit_join` where cou_gro_id = #{groupId} AND tea_id=#{teacherId}")
    @ResultType(Integer.class)
    Integer deleteAuditJoin(String groupId,String teacherId);


    //查询某一课程组中老师人数
    @Select("select count(*) from tea_course_group where cou_gro_id=#{groupId}")
    @ResultType(Integer.class)
    Integer findTeacherCountByGroupId(String groupId);

    //查询课程组中所有的老师(分页）
    @Select("select tea_id from tea_course_group where cou_gro_id = #{groupId} limit #{nowPage},#{rows}")
    @ResultType(Teacher.class)
    List<Teacher> getTeacherByGroupId(String groupId,Integer nowPage,Integer rows);

    //查询课程组中所有的老师（不分页）
    @Select("select tea_id from tea_course_group where cou_gro_id = #{groupId}")
    @ResultType(Teacher.class)
    List<Teacher> getTeacherByGroId(String groupId);
    //查询课程组的组长
    @Select("select tea_id from tea_course_group where cou_gro_id = #{groupId} and group_leader = #{groupLeader}")
    @ResultType(String.class)
    String getLeaderByGroupId(String groupId,Integer groupLeader);



    @Select("select cou_gro_id from tea_course_group where tea_id = #{id}")
    @ResultType(String.class)
    List<String> getCourseGroupData(String id);


}

